Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
before fix:
org.apache.storm.trident.partition.IndexHashGrouping
public static int objectToIndex(Object val, int numPartitions) { if(val==null) return 0; else { return Math.abs(val.hashCode()) % numPartitions; } }
If the hashcode is Integer.MIN_VALUE, then the result will be negative as well (since Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE).
after fix:
Use toPositive replace Math.abs:
public static int toPositive(int number) { return number & Integer.MAX_VALUE; }